package com.freesky.provider.order.controller;

import com.freesky.common.dao.entity.Address;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.provider.order.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 14:29 2018/11/29
 * @description:
 */
@RestController
public class AddressController {

    @Autowired
    private IAddressService addressService;

    @PostMapping(value = "/member/address/list")
    public JSONResponse addressList(@RequestBody Address address){

        JSONResponse addressList = addressService.getAddressList(address.getUserId());
        return addressList;
    }

    @PostMapping(value = "/member/address")
    public JSONResponse address(@RequestBody Address address){

        return addressService.getAddress(address.getAddressId());
    }

    @PostMapping(value = "/member/address/add")
    public JSONResponse addAddress(@RequestBody Address address){

        return addressService.addAddress(address);
    }

    @PostMapping(value = "/member/address/update")
    public JSONResponse updateAddress(@RequestBody Address address){

        return addressService.updateAddress(address);
    }

    @PostMapping(value = "/member/address/del")
    public void delAddress(@RequestBody Address address){
       addressService.delAddress(address);
    }
}
